home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / fpoint.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-11-03  |  4.1 KB  |  132 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. /***************************************************************************
  8.                           fpoint.h  -  description
  9.                              -------------------
  10.     begin                : Mit Jul 24 2002
  11.     copyright            : (C) 2002 by Franz Schmid
  12.     email                : Franz.Schmid@altmuehlnet.de
  13.  ***************************************************************************/
  14.  
  15. /***************************************************************************
  16.  *                                                                         *
  17.  *   This program is free software; you can redistribute it and/or modify  *
  18.  *   it under the terms of the GNU General Public License as published by  *
  19.  *   the Free Software Foundation; either version 2 of the License, or     *
  20.  *   (at your option) any later version.                                   *
  21.  *                                                                         *
  22.  ***************************************************************************/
  23.  
  24. #ifndef FPOINT_H
  25. #define FPOINT_H
  26.  
  27. #include <QMatrix>
  28. #include <QPoint>
  29. #include "scribusapi.h"
  30. /**
  31.   *@author Franz Schmid
  32.   */
  33.  
  34. class SCRIBUS_API FPoint
  35. {
  36. public: 
  37.     FPoint() : xp(0), yp(0) {};
  38.     FPoint(double x, double y) : xp(x), yp(y) {};
  39.     FPoint(const QPoint & p) : xp(p.x()), yp(p.y()) {};
  40.     FPoint(const FPoint & p) : xp(p.xp), yp(p.yp) {};
  41.     //Creates a transformed point, replaces ScribusView::transformPoint()
  42.     FPoint(const double x, const double y, const double dx, const double dy, const double rot, const double sx, const double sy, const bool invert=false);
  43. //  ~FPoint() {};
  44.     FPoint &  operator=(const FPoint & rhs);
  45.     double x() const;
  46.     double y() const;
  47.     void setX(double x);
  48.     void setY(double y);
  49.     void setXY(double x, double y);
  50.     bool operator==(const FPoint &rhs) const;
  51.     bool operator!=(const FPoint &rhs) const;
  52.     FPoint &operator+=( const FPoint &p );
  53.     FPoint &operator-=( const FPoint &p );
  54.     friend inline const FPoint operator+( const FPoint &, const FPoint & );
  55.     friend inline const FPoint operator-( const FPoint &, const FPoint & );
  56.     friend inline const FPoint operator*( const FPoint &, const double & );
  57.     friend inline const FPoint operator*( const double &, const FPoint & );
  58.     friend inline double  operator*( const FPoint &a, const FPoint &b );
  59.     //Transform an existing point
  60.     void transform(const double dx, const double dy, const double rot, const double sx, const double sy, const bool invert);
  61.     //Transform an existing point, return a new one
  62.     FPoint transformPoint(const QMatrix& m, const bool invert) const;
  63.     FPoint transformPoint(const double dx, const double dy, const double rot, const double sx, const double sy, const bool invert) const;
  64.     friend class FPointArray;
  65.  
  66. private:
  67.     double xp;
  68.     double yp;
  69. };
  70.  
  71.  
  72. inline const FPoint operator+( const FPoint &p1, const FPoint &p2 ) { 
  73.     return FPoint(p1.xp+p2.xp, p1.yp+p2.yp); 
  74. }
  75.  
  76. inline const FPoint operator-( const FPoint &p1, const FPoint &p2 ) { 
  77.     return FPoint(p1.xp-p2.xp, p1.yp-p2.yp); 
  78. }
  79.  
  80. inline const FPoint operator*( const FPoint &p, const double &c ) { 
  81.     return FPoint(p.xp*c, p.yp*c); 
  82. }
  83.  
  84. inline const FPoint operator*( const double &c, const FPoint &p ) { 
  85.     return FPoint(p.xp*c, p.yp*c); 
  86. }
  87.  
  88. inline double operator*( const FPoint &a, const FPoint &b ) {
  89.     return a.xp * b.xp + a.yp * b.yp; 
  90. }
  91.  
  92. inline FPoint &  FPoint::operator=(const FPoint & rhs)  { 
  93.     xp = rhs.xp; 
  94.     yp = rhs.yp; 
  95.     return *this; 
  96. }
  97.  
  98. inline double FPoint::x() const { 
  99.     return xp; 
  100. }
  101.  
  102. inline double FPoint::y() const { 
  103.     return yp; 
  104. }
  105.  
  106. inline void FPoint::setX(double x) { 
  107.     xp = x; 
  108. }
  109.  
  110. inline void FPoint::setY(double y) { 
  111.     yp = y; 
  112. }
  113.  
  114. inline void FPoint::setXY(double x, double y) { 
  115.     xp = x;
  116.     yp = y; 
  117. }
  118.  
  119. inline FPoint & FPoint::operator+=( const FPoint &p ) { 
  120.     xp += p.xp; 
  121.     yp += p.yp; 
  122.     return *this; 
  123. }
  124.  
  125. inline FPoint & FPoint::operator-=( const FPoint &p ) { 
  126.     xp -= p.xp; 
  127.     yp -= p.yp; 
  128.     return *this; 
  129. }
  130.  
  131. #endif
  132.